package com.testing.class12;

import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import java.io.IOException;

/**
 * @Classname PutAndDelDemo
 * @Description 类型说明
 * @Date 2022/10/31 22:16
 * @Created by 特斯汀Roy
 */
public class PutAndDelDemo {
    public static void main(String[] args) throws IOException {
        CloseableHttpClient aDefault = HttpClients.createDefault();
        HttpPut put=new HttpPut("http://localhost:9090/hello/updateUser");
        StringEntity userAndNick=new StringEntity("username=roy&nickname=肉肉老师","utf-8");
        userAndNick.setContentType("application/x-www-form-urlencoded");
        put.setEntity(userAndNick);
        String s = EntityUtils.toString(aDefault.execute(put).getEntity(), "utf-8");
        System.out.println(s);


        HttpDelete delete=new HttpDelete("http://localhost:9090/hello/deleteUser/rouyi");
        String s1 = EntityUtils.toString(aDefault.execute(delete).getEntity(), "utf-8");
        System.out.println(s1);

    }
}
